// import request from '../config'
import request from '../config/indexNew'
/**
 *  获取用户信息
 **/
// export const getUserInfo = () => {
//   const url = '/UserInfo/Self'
//   return request(url)
// }
// /**
//  *  退出登陆
//  **/
// export const logout = () => {
//   const url = '/System/Quit'
//   return request(url)
// }
// /**
//  *  获取标签列表
//  **/
// export const getTagList = () => {
//   const url = '/UserInfo/TagList'
//   return request(url)
// }

// // 客户群列表
// export const getGroupList = () => {
//   const url = '/UserInfo/GroupchatList'
//   return request(url)
// }
// // 选择文件
// export const getSelectFilePath = (data: any) => {
//   const url = '/System/SelectFile'
//   return request(url, data)
// }
// // 文件导出
// export const getSystemExport = (data: any) => {
//   const url = '/System/Export'
//   return request(url, data)
// }
// // 同步企微数据
// export const getSystemSync = () => {
//   const url = 'System/Sync'
//   return request(url)
// }
// 获取个人信息
export const getUserInfo = (data?: any) => {
  return request({
    url: '/api/win-tool/userinfo/self',
    method: 'POST',
    data
  })
}
/**
 *  退出登陆
 **/
export const logout = (data?: any) => {
  return request({
    url: '/api/win-tool/System/Quit',
    method: 'POST',
    data
  })
}

/**
 *  获取标签列表
 **/
export const getTagList = (data?: any) => {
    return request({
      url: '/api/win-tool/userinfo/tag/list',
      method: 'POST',
      data
    })
  }

/**
 *  刷新标签列表
 * @description 接口会先执行同步标签，然后再获取标签列表
**/
export const refreshTagDataList = (data?: any) => {
    return request({
        url: '/api/win-tool/userinfo/tag/list-refresh',
        method: 'POST',
        data
    })
}

// 客户群列表
export const getGroupList = (data?: any) => {
  return request({
    url: '/api/win-tool/userinfo/groupchat/list',
    method: 'POST',
    data
  })
}
// 选择文件
export const getSelectFilePath = (data: any) => {
  return request({
    url: '/api/win-tool/System/SelectFile',
    method: 'POST',
    data
  })
}
// 文件导出
export const getSystemExport = (data: any) => {
  return request({
    url: '/api/win-tool/System/Export',
    method: 'POST',
    data,
    responseType: 'arraybuffer'
  })
}
// 同步企微数据
export const getSystemSync = (data?: any) => {
  return request({
    url: '/api/win-tool/System/Sync',
    method: 'POST',
    data
  })
}

// 上传文件
export const fileUpload = (file: any) => {
  return request({
    url: '/api/common/file/upload',
    method: 'POST',
    data: file
  })
}

// 小程序
export const miniProgramList = (data: any) => {
  return request({
    url: '/api/common/mini-program/list',
    method: 'POST',
    data
  })
}

// 新增小程序
export const miniProgramPut = (file: any) => {
  return request({
    url: '/api/common/mini-program/put',
    method: 'POST',
    data: file
  })
}

// 删除小程序配置
export const miniProgramDel = (data: any) => {
  return request({
    url: '/api/common/mini-program/del',
    method: 'POST',
    data
  })
}

// 上传文件
export async function uploadFile2(file: any, beforeCallback?: any) {
    // 取消请求
    const controller = new AbortController();
    const formData = new FormData()
    formData.append('file', file);
    beforeCallback?.(controller)
    const res: any = await request({
        url: '/api/common/file/upload-v2',
        data: formData,
        method: 'post',
        signal: controller.signal
    });
    return res
}